<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS练习题</title>
    <style>
        /*水平垂直居中  绝对定位方法      */
        .box{
            position: absolute;
            top: 50%;
            left: 50%;
            width: 50px;
            height: 50px;
            background: aqua;
            transform: translate(-50%,-50%);
        }
        /*水平垂直居中  flex方法      */
        .wrap{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 200px;
            width: 200px;
            background: rgba(0,0,0,.3);
        }
        .box2{
            width: 50px;
            height: 50px;
            background: salmon;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <div class="wrap">
        <div class="box2"></div>
    </div>
</body>
</html>